﻿
'渲染器基类
Public Class renderer

    Sub New()
        m_DC = main.g_Graphic
    End Sub

    Public Sub InitRenderer()
        m_Buffer = New Bitmap(main.Width, main.Height)
        m_BufferDC = Graphics.FromImage(m_Buffer)
        m_Pen = New Pen(Color.Black)
        m_Brush = New SolidBrush(Color.White)
    End Sub

    'DO NOT USE IF REALLY NEED
    Public Sub SetDC(ByRef dc As Graphics)
        m_DC = dc
    End Sub

    Public Overridable Sub Render()
        m_DC.DrawImage(m_Buffer, 0, 0)
    End Sub

    Public Overridable Sub BufferRender()
        
    End Sub

    Public Overridable Sub RenderEx()
        BufferRender()
        Render()
    End Sub

    Protected Shared m_BufferDC As Graphics
    Protected Shared m_Buffer As Bitmap
    Protected Shared m_DC As Graphics
    Protected m_Pen As Pen
    Protected m_Brush As Brush

End Class

'画板渲染器
Public Class CanvasRenderer
    Inherits renderer

    Sub New()
        MyBase.New()
        InitRenderer()
        AddHandler main.PaintEvent, AddressOf Me.paint
    End Sub

    Protected Overridable Sub paint(ByRef sender As System.Object, ByRef e As System.Windows.Forms.PaintEventArgs)
        e.Graphics.DrawImage(m_Buffer, 0, 0)
    End Sub

    

End Class
